package com.example.tdam;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class HistorialData extends SQLiteOpenHelper implements Constants {

	private static final String DATABASE_NAME = "tdam.db";
	private static final int DATABASE_VERSION = 11;
	
	public HistorialData(Context context)
	{
		super(context, DATABASE_NAME, null, DATABASE_VERSION);		
	}
	
	public HistorialData(Context context, String name, CursorFactory factory,
			int version) {
		super(context, DATABASE_NAME, factory, DATABASE_VERSION);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		db.execSQL("CREATE TABLE " + TABLE_NAME + " (" + _ID
				+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + ID_CONTACTO_COLUMN
				+ " INTEGER, " + NOMBRE_CONTACTO_COLUMN + " TEXT NOT NULL, " + ACCION_COLUMN + " TEXT NOT NULL, " 
				+ DIRECCION_COLUMN + " TEXT NOT NULL, " + UBICACION_COLUMN + " TEXT NOT NULL)");
		
		db.execSQL("create index contacto_id_idx on " + TABLE_NAME + "(" + ID_CONTACTO_COLUMN + ");");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
		onCreate(db);
	}

}